﻿using Md.Api.Model.Manage.SysRole.Request;
using Md.Dapper.Repositories.Md;

namespace Md.Api.Service.Manage.SysRole;
/// <summary>
/// 通过角色编号获取系统角色服务
/// </summary>
public class GetSysRoleByRoleIdService : ApiBase<RequestGetSysRoleByRoleIdModel>
{
    /// <summary>
    /// 系统角色仓储
    /// </summary>
    public SysRoleRep sysRoleRep { get; set; }
    /// <summary>
    /// 系统角色菜单关联仓储
    /// </summary>
    public SysRoleMenuRep sysRoleMenuRep { get; set; }
    /// <summary>
    /// 执行
    /// </summary>
    protected override void ExecuteMethod()
    {
        var roleData = sysRoleRep.GetSysRoleByRoleId(Parameter.RoleId);

        var menus = sysRoleMenuRep.GetSysRoleMenuListByRoleId(Parameter.RoleId);

        Result.Data = new { role = roleData, menuIds = menus.Select(s => s.MenuId) };
    }
}
